package il.ac.braude.sona.gui.mytables;

import il.ac.braude.sona.entities.ChangeRequest;
import il.ac.braude.sona.gui.list_table.ListTableModel;

import java.util.ArrayList;

import javax.swing.event.TableModelListener;
/**
 * Table model for ChangeRequests
 * @author  Ofek Ron
 * @author Avihay Avitan
 * @author Nitzan Inbar
 * @author Sasha Rozenthal
 * Group 6,<br>Laboratory in Software Engineering,Ort Braude College.</p>
 *
 */
public class ChangeRequestTableModel extends ListTableModel<ChangeRequest>{
	private ArrayList<TableModelListener> listeners = new ArrayList<TableModelListener>();
	/**
	 * make a trabkle model from an array of change requests
	 * @param req
	 */
	public ChangeRequestTableModel(ArrayList<ChangeRequest> req) {
		super(req);
	}

	@Override
	public void addTableModelListener(TableModelListener l) {
		if (!listeners.contains(l))
			listeners.add(l);
	}

	@Override
	public Class<?> getColumnClass(int arg0) {
		return String.class;
	}

	@Override
	public int getColumnCount() {
		return ChangeRequest.summary_fields.length;
	}

	@Override
	public String getColumnName(int i) {
		return ChangeRequest.summary_fields[i];
	}



	@Override
	public Object getValueAt(int i, int j) {
		return get(i).getValue(getColumnName(j));
	}

	@Override
	public boolean isCellEditable(int arg0, int arg1) {
		return false;
	}

	@Override
	public void removeTableModelListener(TableModelListener l) {
		listeners.remove(l);
	}

	@Override
	public void setValueAt(Object arg0, int arg1, int arg2) {
	}
}
